
// POSIX Threads

// $Id: PThread.hpp 2 2012-05-22 17:55:16Z gerry@gaboury.biz $

#ifndef PTHREAD_HPP
#define PTHREAD_HPP

#include <vector>

using namespace std;

#include <pthread.h>

// typedef Vector<T>& (*ODE_Func<T>) (T, const Vector<T>&);
typedef void* (*thread_routine) (void*);

// the master control

class PThread
{
private:
  static PThread* s_instance;
  // list of thread identifiers
  vector<pthread_t> m_ThreadID;
  PThread() { }
public:
  static PThread* instance();
  virtual ~PThread() { }
  // accessor
  int count() const { return m_ThreadID.size(); }
  
  // count is the number of threads required
  void AddThreads ( int count, thread_routine tr, void* arg );
  void AddThread ( thread_routine tr, void* arg );

  // join with return value
  void join(void**);
  // join without return value
  void join();
};


#endif // PTHREAD_HPP
